package de.riceman.simpleGo.view.forms;

import java.util.ArrayList;

import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;

import org.springframework.binding.form.FormModel;
import org.springframework.richclient.application.Application;
import org.springframework.richclient.form.AbstractForm;
import org.springframework.richclient.form.binding.swing.SwingBindingFactory;
import org.springframework.richclient.form.builder.TableFormBuilder;

import de.riceman.simpleGo.main.GoGame;
import de.riceman.simpleGo.main.HumanMoveSetup;

public class HumanMoveForm extends AbstractForm {

	static HumanMoveSetup humanMoveSetup = new HumanMoveSetup();

	ArrayList<String> coordinates;

	public HumanMoveForm(FormModel model) {
		super(model, "humanMoveForm");
	}
	
	public JComponent createFormControl() {
		
		coordinates = new ArrayList<String>();
		
		GoGame goGame = (GoGame) Application.instance().getApplicationContext().getBean("GoGame");
		
		for (int i = 0; i < goGame.getConfiguration().getSize(); i++) {
			coordinates.add(Integer.toString(i));
		}
				
		SwingBindingFactory bindingFactory = (SwingBindingFactory) getBindingFactory(); 
		
		TableFormBuilder builder = new TableFormBuilder(getBindingFactory());
		builder.add(bindingFactory.createBoundComboBox("xPos", coordinates));
		builder.row();
		builder.add(bindingFactory.createBoundComboBox("yPos", coordinates));
		builder.row();
		builder.add("pass");
		builder.row();
		JPanel panel = (JPanel) builder.getForm();
		panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

		return panel;
	} 
}